﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.DirectX.Direct3D;
using Microsoft.DirectX;
using EdytorWF.Settings;
using EdytorWF.Engine;
using System.ComponentModel;
using System.Windows.Forms.Design;
using System.Drawing.Design;

namespace EdytorWF.Objects
{
    public abstract class IObject
    {
        private static int counter = 0;
        public int ObjectId { get; set; }
        public String ObjectName { get; set; }
        public String TypeName { get; set; }

        private String _TypeName;

        [Editor(typeof(FileNameEditor), typeof(UITypeEditor))]
        public String MeshFileName
        {
            get
            {
                return _TypeName;
            }
            set
            {
                _TypeName = value;
                ReloadMesh();
            }
        }
        private String _TextureFileName;

        [Editor(typeof(FileNameEditor), typeof(UITypeEditor))]
        public String TextureFileName
        {
            get
            {
                return _TextureFileName;
            }
            set
            {
                _TextureFileName = value;
                ReloadTexture();
            }
        }

        protected Device Device { get; set; }
        protected Mesh MyMesh { get; set; } // Siatka obiektu
        protected List<ExtendedMaterial> ExtendedMaterials { get; set; }
        protected List<Texture> Textures { get; set; }
        protected List<Material> Materials { get; set; }

        public BoundingBox CollisionBox { get; set; }
        public VertexDeclaration vd;
        public VertexBuffer vb;

        public String GetTypeName() { return TypeName; }
        protected IObject()
        {
            ObjectId = counter;
            counter++;
        }
        public void SetDevice(Device dev)
        {
            Device = dev;
        }
        public virtual void Render() { }
        public abstract void Render(ref Effect effect, String texture, bool with_lights = true);
        public abstract void LoadTexture(string FileName);
        public abstract void LoadMesh(string FileName);
        public virtual void ReloadTexture() { }
        public virtual void ReloadMesh() { }
        public abstract void ReloadObject();

    }
}
